home *** CD-ROM | disk | FTP | other *** search
- /* ==========================================================================
- Action routines for the LDAP CSAM.
-
- Written by: Gavin Eadie • The University of Michigan Information Systems
- Phone: (313) 936-0816
- AppleLink: A67
- Internet: gavin@umich.edu
-
- History: Apr18/91 1.0d1 Start
- Oct22/91 Start again (Gav)
- Apr22/92 1.0d3 Finally get back to this (Gav)
- Apr29/92 1.0d4 ... making progress (Gav)
- May09/92 1.0d5 ... WWDC Version (Gav)
- May22/92 1.0d6 post WWDC changes [dash->DSAM] ... Gav
- Aug14/92 1.0d7 OCE Alpha 8 changes - MANY!! (Gav)
- Aug24/92 1.0a1 version to alpha - continuing changes (Gav)
- Sep08/92 1.0a2 _Procs, _Parse & _Authi split off ... (Gav)
- Sep22/92 1.0a3 Return the stubs of the _Procs, _Parse &
- _Authi routines to this file because the
- periodic timer that drives asynch stuff
- lives here too.
- Jan04/93 1.0a10 First try with AOCE a13 ... Gav
- Jan21/93 1.0a13 reduce to 7 (iconCount) icon resources ... Gav
- Jan27/93 1.0a14 no revisions for AOCE 1.0a14 ... Gav
- Mar10/93 1.0a16 all MacsBug calls removed ... Gav
- Mar16/93 1.0a17 revisions for AOCE 1.0b1 ... Gav
- Jun01/93 1.0a23 remove «displayName» from pSect ... Gav
-
- Jan18/94 1.0b20 increase audit log to 128 entries ... Gav
-
- ========================================================================== */
-
- #include "Headers.H"
-
- OSErr Locate_Icon(struct Icon_Data * Icon, ResType Type);
-
- // --------------------------------------------------------------------------
- // CSAM_Open • Initialise the dash code.
- //
- // Since we are really a driver, we need to grab some working memory
- // and link it to the dCtl - we do that first, then we initialize the
- // various CSAM attributes.
- // --------------------------------------------------------------------------
- OSErr CSAM_Open(CntrlParam * ctlPB, DCtlPtr dCtl) {
- register MyDashGlobals * dGlobals;
- Handle displayName; // Display Name for the CSAM
- DirParamBlock Dir_Param;
- OSErr result;
-
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // if there is no working storage, get some - if there is, return happy.
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- if (nil == dCtl->dCtlStorage) {
- if (nil == (dCtl->dCtlStorage = NewHandleSysClear(sizeof(MyDashGlobals))))
- result = memFullErr; // no memory - no Globals
- else {
- HLock(dCtl->dCtlStorage);
-
- dGlobals = (MyDashGlobals *)(*dCtl->dCtlStorage);
-
- #ifdef AUDIT
- dGlobals->Audit_Ptr = InitAudit('ldap', 128, true, false);
- #endif
- Audit_PString('CSAM', "\pCSAM_Open: Started");
-
- dGlobals->CSAM_Q.qFlags = 0;
- dGlobals->CSAM_Q.qHead = nil;
- dGlobals->CSAM_Q.qTail = nil;
-
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // get the display name ... use an 'rstr' resource
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- displayName = Get1NamedResource('rstr', "\pDisplay Name");
- if (nil == displayName) {
- Audit_PString('CSAM', "\pCSAM_Open: Get('Display Name')");
- return (memFullErr);
- }
- HLock(displayName);
- DetachResource(displayName);
-
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // get the icon resources (7 of them) ...
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Locate_Icon(&dGlobals->Icon[0], 'ICN#');
- Locate_Icon(&dGlobals->Icon[1], 'icl8');
- Locate_Icon(&dGlobals->Icon[2], 'icl4');
-
- Locate_Icon(&dGlobals->Icon[3], 'ics#');
- Locate_Icon(&dGlobals->Icon[4], 'ics8');
- Locate_Icon(&dGlobals->Icon[5], 'ics4');
-
- Locate_Icon(&dGlobals->Icon[6], 'SICN');
-
- dGlobals->ldap_Other_Hdl = Get1Resource('rstr', otherRStrID);
- if (nil != dGlobals->ldap_Other_Hdl && noErr == ResError()) {
- HLock(dGlobals->ldap_Other_Hdl);
- DetachResource(dGlobals->ldap_Other_Hdl);
- }
- else {
- Audit_PString('CSAM', "\pMissing 'ldap Other' RStr");
- return (memFullErr);
- }
-
- dGlobals->Delta_Count = 0; // initialize changes counter
-
- Dir_Param.instantiateDSAMPB.dsamName = (RStringPtr)*displayName;
- Dir_Param.instantiateDSAMPB.dsamKind = skelType;
- Dir_Param.instantiateDSAMPB.dsamData = (Ptr)dGlobals;
- #ifdef UNIVERSAL_HEADERS
- Dir_Param.instantiateDSAMPB.dsamDirProc = (DSAMDirUPP)CSAM_Procs;
- Dir_Param.instantiateDSAMPB.dsamDirParseProc = (DSAMDirParseUPP)CSAM_Parse;
- #else
- Dir_Param.instantiateDSAMPB.dsamDirProc = (ProcPtr)CSAM_Procs;
- Dir_Param.instantiateDSAMPB.dsamDirParseProc = (ProcPtr)CSAM_Parse;
- #endif
- result = DirInstantiateDSAM(&Dir_Param);
- }
- }
- return (ctlPB->ioResult = result);
- }
-
-
- // --------------------------------------------------------------------------
- // CSAM_Control • Called by periodic timer.
- // --------------------------------------------------------------------------
- OSErr CSAM_Control(CntrlParam * ctlPB, DCtlPtr dCtl) {
- #pragma unused (ctlPB)
- MyDashGlobals * dGlobals = (MyDashGlobals *)(*dCtl->dCtlStorage);
-
- if (nil != dGlobals->CSAM_Q.qHead) {
- if (noErr == Dequeue(dGlobals->CSAM_Q.qHead, &(dGlobals->CSAM_Q))) {
- }
- }
-
- return (noErr);
- }
-
-
- /* --------------------------------------------------------------------------
- CSAM_Prime • No longer called (after OCE alpha 8).
- -------------------------------------------------------------------------- */
- OSErr CSAM_Prime(CntrlParam * ctlPB, DCtlPtr dCtl) {
- #pragma unused (ctlPB)
- MyDashGlobals * dGlobals = (MyDashGlobals *)(*dCtl->dCtlStorage);
-
- return (noErr);
- }
-
-
- /* --------------------------------------------------------------------------
- CSAM_Status • No longer called (after OCE alpha 8).
- -------------------------------------------------------------------------- */
- OSErr CSAM_Status(CntrlParam * ctlPB, DCtlPtr dCtl) {
- #pragma unused (ctlPB)
- MyDashGlobals * dGlobals = (MyDashGlobals *)(*dCtl->dCtlStorage);
-
- return (noErr);
- }
-
-
- /* --------------------------------------------------------------------------
- CSAM_Close • release storage.
- -------------------------------------------------------------------------- */
- OSErr CSAM_Close(CntrlParam * ctlPB, DCtlPtr dCtl) {
- #pragma unused (ctlPB)
- MyDashGlobals * dGlobals = (MyDashGlobals *)(*dCtl->dCtlStorage);
-
- if (nil != dGlobals) {
- short i;
-
- for (i = 0; i < iconCount; i++) {
- if (nil != dGlobals->Icon[i].iconHandle) {
- HUnlock(dGlobals->Icon[i].iconHandle);
- ReleaseResource(dGlobals->Icon[i].iconHandle);
- }
- }
- DisposHandle(dCtl->dCtlStorage);
- dCtl->dCtlStorage = nil;
- }
-
- return (noErr);
- }
-
-
- /* --------------------------------------------------------------------------
- CSAM_Procs • get and information functions
-
- -------------------------------------------------------------------------- */
- pascal OSErr CSAM_Procs(void * dashData, DirParamBlockPtr ds_PB, Boolean async) {
- register MyDashGlobals * dGlobals = (MyDashGlobals * )dashData;
- OSErr Dir_Error = kOCEParamErr;
-
- Audit_PString('PROX', (async ? "\p----->(async)" : "\p----->(synch)"));
-
- if (async) {
- // Enqueue((QElemPtr) ds_PB, &(dGlobals->CSAM_Q));
- Dir_Error = Dir_Procs(dGlobals, ds_PB);
- io_Complete(ds_PB, Dir_Error);
-
- return (noErr);
- }
- else
- return (ds_PB->header.ioResult = Dir_Procs(dGlobals, ds_PB));
-
- }
-
-
- /* --------------------------------------------------------------------------
- CSAM_Parse • parse functions
-
- -------------------------------------------------------------------------- */
- pascal OSErr CSAM_Parse(void * dashData, DirParamBlockPtr ds_PB, Boolean async) {
- register MyDashGlobals * dGlobals = (MyDashGlobals * )dashData;
- OSErr Dir_Error = kOCEParamErr;
-
- Audit_PString('PARZ', (async ? "\p----->(async)" : "\p----->(synch)"));
-
- if (async) {
- // Enqueue((QElemPtr) ds_PB, &(dGlobals->CSAM_Q));
- Dir_Error = Dir_Parse(dGlobals, ds_PB);
- io_Complete(ds_PB, Dir_Error);
-
- return (noErr);
- }
- // else
- return (ds_PB->header.ioResult = Dir_Parse(dGlobals, ds_PB));
-
- }
-
-
- /* --------------------------------------------------------------------------
- Locate_Icon • utility function
-
- -------------------------------------------------------------------------- */
- OSErr Locate_Icon(struct Icon_Data * Icon, ResType Type) {
- OSErr Res_Error = noErr;
-
- Icon->iconType = Type;
- Icon->iconLength = 0;
- Icon->iconHandle = Get1Resource(Type, 1000);
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // don't forget that ResError() can return noErr when GetResource
- // doesn't find the resource so check for both possibilities ...
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- if (nil != Icon->iconHandle && noErr == (Res_Error = ResError())) {
- HLock(Icon->iconHandle);
- DetachResource(Icon->iconHandle);
- Icon->iconLength = GetHandleSize(Icon->iconHandle);
- }
- return (Res_Error);
- }
-